package naga.x.platform2.channel.jg.support;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import naga.x.platform2.App;
import naga.x.platform2.app.Channel;

@Configuration
@EnableAutoConfiguration
@ConfigurationProperties(locations = "classpath:9g.properties")
public class JGConfig implements InitializingBean {

	private String spId;
	private String spKey;
	private String gameId;
	private String clientUrl;
	private String userInfoUrl9G;
	private boolean debug;
	
	public String getSpId() {
		return spId;
	}

	public void setSpId(String spId) {
		this.spId = spId;
	}

	public String getSpKey() {
		return spKey;
	}

	public void setSpKey(String spKey) {
		this.spKey = spKey;
	}

	public String getGameId() {
		return gameId;
	}

	public void setGameId(String gameId) {
		this.gameId = gameId;
	}

	public String getClientUrl() {
		return clientUrl;
	}

	public void setClientUrl(String clientUrl) {
		this.clientUrl = clientUrl;
	}

	public String getUserInfoUrl9G() {
		return userInfoUrl9G;
	}

	public void setUserInfoUrl9G(String userInfoUrl9G) {
		this.userInfoUrl9G = userInfoUrl9G;
	}

	public boolean isDebug() {
		return debug;
	}

	public void setDebug(boolean debug) {
		this.debug = debug;
	}

	@Override
	public String toString() {
		return "[spId=" + spId + ", spKey=" + spKey + ", gameId=" + gameId + ", clientUrl=" + clientUrl
				+ ", userInfoUrl9G=" + userInfoUrl9G + ", debug=" + debug + "]";
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		Channel.JG.debug = debug;
		App.LOG.info("[9G CONFIG LOADED]{}", this);
	}

}
